//<template>
    <div>
        标题：<input type="text" v-model="title">
        跳转地址：<input type="text" v-model="link">
        图片地址：<input type="text" v-model="image">
        <Button @click="insert">提交</Button><br>
        <br><br><br><br>
        <ul>
            <li v-for="(item,index) in params" :key="index">
                标题：{{item.title}}
                跳转地址：{{item.link}}
                图片地址：{{item.image}}
                <Button @click="delpics(item.id)">删除</Button>
            </li>
        </ul>
    </div>
</template>

<script>
import {config} from '../config'
export default {
    data(){
        return {
            title:"",
            link:"",
            image:"",
            adminurl:config['adminurl'],
            params:[]
        }
    },
    mounted(){
        this.getpics()
    },
    methods:{
        insert(){
            this.axios({
                url:this.adminurl + "/insertpics/",
                method:"POST",
                data:{
                    title:this.title,
                    link:this.link,
                    image:this.image
                }
            })
            .then(res=>{
                console.log(res)
            })
        },
        getpics:function(){
		  this.axios.get(this.adminurl+"/insertpics/").then(res=>{
			  this.params = res.data

		  })
      },
      delpics(id){
          this.axios({
              url:this.adminurl+"/insertpics/",
              method:"DELETE",
              params:{
                  "id":id
              }
          })
          .then(res=>{
              console.log(res)
          })
      }
    }
}
</script>

<style>

</style>
